package com.xsmart.goods.api;

import com.xsmart.common.entity.RequestBean;
import com.xsmart.common.entity.ResponseBean;
import com.xsmart.goods.services.AttributeService;
import com.xsmart.goods.services.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/api")
public class AttributeController {

    @Autowired
    AttributeService attributeService;

    @RequestMapping(value = "/v1/AttributeService/queryAttr", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean queryAttr(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return attributeService.queryAttr(requestBean);
    }

    @RequestMapping(value = "/v1/AttributeService/addAttr", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean addAttr(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return attributeService.addAttr(requestBean);
    }

    @RequestMapping(value = "/v1/AttributeService/modAttr", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean modAttr(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return attributeService.modAttr(requestBean);
    }

    @RequestMapping(value = "/v1/AttributeService/delAttr", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean delAttr(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return attributeService.delAttr(requestBean);
    }

    @RequestMapping(value = "/v1/AttributeService/queryAll", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean queryAll(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return attributeService.queryAll(requestBean);
    }


    @RequestMapping(value = "/v1/AttributeService/queryGoodsTypeName", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean queryGoodsTypeName(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return attributeService.queryGoodsTypeName(requestBean);
    }
}
